# -*- coding:utf-8 -*-
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None
class Solution:
    # 返回对应节点TreeNode
    def KthNode(self, p, k):
        # write code here
        if not p or k <= 0:
            return None
        self.a = []
        self.help(p)
        if k > len(self.a):
            return None
        return self.a[k - 1]

    def help(self, node):
        if not node:
            return None
        self.help(node.left)
        self.a.append(node)
        self.help(node.right)
        return 0
